import inspect
from functools import wraps, lru_cache

def check(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        pass
        params = inspect.signature(func).parameters
        par = tuple(params.values())
        for k,v in enumerate(args):
            if not isinstance(v,par[k].annotation) and par[k].annotation is not par[k].empty :
                print("可变位置参数类型错误: {} is not {}".format(par[k].name,par[k].annotation))
        for k,v in kwargs.items():
            if not isinstance(v,params.get(k).annotation) and params.get(k).annotation is not params.get(k).empty:
                print("可变关键字参数类型错误: {} is not {}".format(params.get(k).name, params.get(k).annotation))
        result = func(*args, **kwargs)
        return result
    return wrapper

@check
def add(x:int, y:int, p:int=7 , q: int=8) -> int:
    pass
#print(add(4, 5))
#print(add('mag', 'edu'))
print(add('mag',2,p='mag', q='edu'))
print(add(1,2,p='mag', q='edu'))
print(add('mag','edu',p='mag', q='edu'))
print(add('mag','edu',p=1, q=2))